package cn.ycc1.boot3aop.proxy;

import cn.ycc1.boot3aop.service.Calculator;

/**
 * 静态代理
 * @author ycc
 * @date 2024/11/6
 *
 * 动态代理：在执行期限间，在运行期间创建代理对象（拦截器的思想）
 */
public class CalculatorStaticProxy implements Calculator {
    private Calculator target;

    public CalculatorStaticProxy(Calculator calculator) {
        this.target = calculator;
    }

    @Override
    public int add(int a, int b) {
        System.out.println("add before...");
        return this.target.add(a, b);
    }

    @Override
    public int sub(int a, int b) {
        System.out.println("sub before...");
        return this.target.sub(a, b);
    }

    @Override
    public int mul(int a, int b) {
        return this.target.mul(a, b);
    }

    @Override
    public int div(int a, int b) {
        return this.target.div(a, b);
    }
}
